<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <jsp:include page="../head.jsp" flush="true">
        <jsp:param name="title" value="后台管理系统 - 用户管理"/>
    </jsp:include>
</head>
<body class="bg-default">
<!-- 头导航 -->
<jsp:include page="../navbar.jsp"/>
<div class="cont-wrap">
    <!-- 左侧菜单 -->
    <jsp:include page="../menu.jsp" flush="true">
        <jsp:param name="page" value="3"/>
    </jsp:include>
    <!-- 正文 -->
    <div class="content container-fluid col-md-10 col-sm-8 col-xs-12">
        <div class="container-fluid margin-top15 no-padding margin-bottom15">
            <form id="form_page" action="${domain}/admin/user/main" method="post">
                <input id="pageIndex" type="hidden" name="page" value="1">
                <div class="col-sm-4">
                    <input type="text" name="mobile" value="${request.mobile}" class="form-control" placeholder="请输入手机号">
                </div>
                <button type="submit" class="btn btn-default" id="save">搜索</button>
            </form>
        </div>

        <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading">用户列表, 用户数量: ${data.total}</div>

            <!-- Table -->
            <table class="table table-hover">
                <thead>
                <tr>
                    <th class="col-sm-3">用户电话号码</th>
                    <th class="col-sm-3">呢称</th>
                    <th class="col-sm-3">注册日期</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${data.list}" var="item">
                    <tr>
                        <td>${item.mobile}</td>
                        <td>${item.nickname}</td>
                        <td><fmt:formatDate value="${item.regTime}" pattern="yyyy-MM-dd HH:mm"/></td>
                    </tr>
                </c:forEach>
                <c:if test="${empty data.list}">
                    <tr>
                        <td colspan="3"> 没有用户数据</td>
                    </tr>
                </c:if>
                </tbody>
            </table>
        </div>

        <!-- 分页 -->
        <nav class="pull-right">
            <c:choose>
                <c:when test="${empty data.list}">
                    <ul class="pagination">
                        <li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>
                    </ul>
                </c:when>
                <c:when test="${!empty data.list}">
                    <ul class="pagination">
                        <c:if test="${!data.isFirstPage}">
                            <li>
                                <a href="javascript:goPage(${data.prePage})" aria-label="Previous"><span
                                        aria-hidden="true">&laquo;</span></a>
                            </li>
                        </c:if>
                        <c:forEach items="${data.navigatepageNums}" var="pageIndex">
                            <li ${data.pageNum eq pageIndex ? 'class="active"' : ''}>
                                <a href="javascript:goPage(${pageIndex})">${pageIndex} <span
                                        class="sr-only">(current)</span></a>
                            </li>
                        </c:forEach>
                        <c:if test="${!data.isLastPage}">
                            <li>
                                <a href="javascript:goPage(${data.nextPage})" aria-label="Next"><span
                                        aria-hidden="true">&raquo;</span></a>
                            </li>
                        </c:if>
                    </ul>
                </c:when>
            </c:choose>
        </nav>
    </div>
</div>
<p style="display: none">
<form id="form1" method="post">
    <input id="id" name="id"/>
</form>
</p>
<!-- 底部 -->
<jsp:include page="../bottom.jsp"/>
<script type="text/javascript">
    function goPage(pageIndex) {
        $("#pageIndex").val(pageIndex);
        $("#form_page").submit();
    }
</script>
</body>
</html>